<?php

RegisterPlugin("Tc_0010", "ActivePlugin_Tc_0010");

function ActivePlugin_Tc_0010()
{
    global $zbp;
    Add_Filter_Plugin('Filter_Plugin_Post_Get', 'Tc_0010_post_get');
}

function Tc_0010_post_get($post,$name){
    global $zbp;
    switch ($name) {
        case 'Intro':
            $GLOBALS['hooks']['Filter_Plugin_Post_Get']['Tc_0010_post_get']=PLUGIN_EXITSIGNAL_RETURN;
            $intro=$post->GetData()['Content'];
            $intro=preg_replace('/[\r\n\s]+/', '', trim((TransferHTML($intro,'[nohtml]'))));
            $intro=str_replace("&nbsp;","",$intro);
            $intro=str_replace('style=""',"",$intro);
            if($post->GetData()['Type']){
                $intro=SubStrUTF8($intro,500)."...";
            }else{
                $intro=SubStrUTF8($intro,125)."...";
            }
            return $intro;
        case 'Img':
            $GLOBALS['hooks']['Filter_Plugin_Post_Get']['Tc_0010_post_get']=PLUGIN_EXITSIGNAL_RETURN;
            $ac=$post->GetData()['Meta'];
            $ad=Unserialize($ac);
            if(empty($ad['pic'])){
                $imgs=GetImagesFromHtml($post->GetData()['Content']);
                if(empty($imgs['0'])){
                    $pic=$zbp->Config('Tc_0010')->proimg;
                }else{
                    $pic=$imgs['0'];
                }
            }else{
                $pic=$ad['pic'];
            }
            $pic = str_replace('{#ZC_BLOG_HOST#}', $zbp->host, $pic);
            return $pic;
        default:
            break;
    }
}